package com.rc.saas.tenant.service.help;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.base.BaseSearch;
import com.rc.saas.tenant.mapper.guide.UserGuideMapper;
import com.rc.saas.tenant.model.help.UserGuide;
import com.rc.saas.tenant.model.help.UserGuideExample;
import com.rc.saas.tenant.vo.help.UserGuideResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author frog
 * @date 2021/3/9
 */
@Service
public class UserGuideServiceImpl implements UserGuideService {

    @Autowired
    private UserGuideMapper userGuideMapper;

    @Override
    public UserGuideMapper getMapper() {
        return userGuideMapper;
    }

    @Override
    public PageInfo<UserGuideResultVo> listUserGuide(BaseSearch baseSearch) {
        PageHelper.startPage(baseSearch.getOffset(), baseSearch.getLimit());
        //类型: 0 目录 1文章 默认0
        List<UserGuideResultVo> userGuides = userGuideMapper.listUserGuide(baseSearch);
        return new PageInfo<UserGuideResultVo>(userGuides);
    }

    @Override
    public PageInfo<UserGuide> listCatalogManagement(BaseSearch baseSearch) {
        PageHelper.startPage(baseSearch.getOffset(), baseSearch.getLimit());
        UserGuideExample example = new UserGuideExample();
        example.createCriteria().andGuideTypeEqualTo("0").andTenantCodeEqualTo(baseSearch.getTenantCode());
        List<UserGuide> userGuides = userGuideMapper.selectByExample(example);
        return new PageInfo<UserGuide>(userGuides);
    }
}
